|
|
|
|
|
|
|
the resulting spaghetti code. This is one reason why Visual Basic and other 4GLs have acquired such a bad reputation. In Java and Visual C++, the dialog and implementation class functionality are separate, which forces you to create nonvisual classes. The larger the project, the more important it is to strictly practice this rule. By small, I mean projects in which you are the only one who will use the software. If one other person is involved, you greatly increase project risks by not practicing well-planned application partitioning. |
|
|
|
|
|
|
|
|
Note If you need more information, browse to http://www.samsona.com periodically. Using the Object Technology link, you will find helpful information on Visual Basic and object-oriented programming. |
|
|
|
|
|
|
|
|
|
An Example of Class Identities |
|
|
|
|
|
|
|
|
Good! You made it. Now for some interesting illustrations to help you remember the object-oriented concepts just discussed. The automotive industry provides one of the best analogies for understanding OOP. Take Chrysler, for instance. Think of it as a base class for the Sebring class of cars. Now, when you go to the Chrysler dealer, you don't actually buy a Sebring, but an instance of it. The instance you buy is the actual Sebring object because you can interact with it by driving it. The Sebring class, then, is a concrete class because with it, the assembly plant knows how to make real-world cars (objects) based on the Sebring class specification (behavior and attributes). |
|
|
|
|
|
|
|
|
The Sebring class has methods (ways of operating) such as ignite the engine, turn the wheels, go in reverse, open doors, adjust speed, and so on. Its properties (or variables or attributes) would be color of car, current speed, maximum speed, light status (off or on), wheel base, wheel size, window tint, cabin style (sunroof, convertible, hardtop), retail price, and so on. When you instantiate a Sebring class into an actual Sebring car, these properties will be filled in by an actor (a human who interacts with a system, such as the automotive engineer or assembly person in the example). Thus, the color might be red, window tint might be dark smoke, wheel size might be 15'', price might be $25,000, and so on. These values, taken together, represent the current state of the object. |
|
|
|
|
|
|
|
|
Did you notice something interesting about the Sebring class? Some of its methods and properties have something in common with other cars Chrysler makes. For instance, all Chrysler cars ignite engines, turn wheels, go in reverse, open doors, adjust speed, and so on. Also, they each have color, wheel size, wheel base, and so on. Instead of re-creating these methods and properties for each subclassed car (subclass means child class), Chrysler created abstract classes such as the H-Body cars, among others. This is a good |
|
|
|
|
|